Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

std.process: Do not kill process group 2 in unittest #10586

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

helmutg
Copy link

@helmutg helmutg commented Dec 12, 2024

When passing a Pid object to tryWait(), its processId will be changed to Pid.terminated, which happens to be -2. Passing this value to kill() will kill the process group 2 on Posix systems. If you run the build and test suite using this process group, the test case will kill the entire build.

Bug-Debian: https://bugs.debian.org/1089007

When passing a Pid object to tryWait(), its processId will be changed to
Pid.terminated, which happens to be -2. Passing this value to kill()
will kill the process group 2 on Posix systems. If you run the build and
test suite using this process group, the test case will kill the entire
build.

Co-authored-by: Emanuele Rocca <ema@debian.org>
Co-authored-by: Jochen Sprickerhof <git@jochen.sprickerhof.de>
Bug-Debian: https://bugs.debian.org/1089007
@dlang-bot
Copy link
Contributor

Thanks for your pull request and interest in making D better, @helmutg! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "master + phobos#10586"

@CyberShadow
Copy link
Member

Thanks, but wouldn't it make more sense to have kill throw ProcessException if it's passed a Pid with pid == terminated? That seems to be the intention of the test.

@helmutg
Copy link
Author

helmutg commented Dec 12, 2024

Thanks, but wouldn't it make more sense to have kill throw ProcessException if it's passed a Pid with pid == terminated? That seems to be the intention of the test.

That is a very reasonable question. Thank you for the review. Is the kill function supposed to be able to kill process groups? Do process groups exist on Windows? Does existing code assume that kill kills process groups? Whether changing kill is better depends on the answers to these questions.

What I am proposing here is a minimum viable solution that makes gcc build rather than fail its build. If changing kill, we change behavior and may break other code that assumes the ability to kill process groups. That seems like a risky affair and it feels unlikely that such a patch would be backported into older gcc releases.

@CyberShadow
Copy link
Member

Is the kill function supposed to be able to kill process groups?

No, I think it is designed to only kill child processes, created using other std.process functions.

Does existing code assume that kill kills process groups?

Seems highly unlikely. The unittest in question seems to assume that kill will throw a ProcessException if pid == terminated, but it passing previously seemed to be accidental and contingent on a process group with the number 2 not existing.

What I am proposing here is a minimum viable solution that makes gcc build rather than fail its build. If changing kill, we change behavior and may break other code that assumes the ability to kill process groups. That seems like a risky affair and it feels unlikely that such a patch would be backported into older gcc releases.

True. We can go forward with this change as well, though I would add a TODO to note that the condition may not be what was originally intended to be tested.

Let's see what other Phobos maintainers say as well. @schveiguy ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants